import React from 'react';
import {Navigate} from "react-router-dom";
import Home from "../pages/home/Home";
import {HomeRecommend} from "../pages/home/HomeRecommend";
import {HomeRanking} from "../pages/home/HomeRanking";
import HomeSong from "../pages/home/HomeSong";
import {Profile} from "../pages/Profile";
import {Login} from "../pages/Login";
import {Category} from "../pages/Category";
import {Mall} from "../pages/Mall";
// import Detail from "../pages/Detail";
// import User from "../pages/User";
import {NotFound} from "../pages/NotFound";

// 路由懒加载
// 懒加载不是初始加载，进入才会加载，所以会报错，这时需要用到Suspense组件
const Detail = React.lazy(() => import('../pages/Detail'))
const User = React.lazy(() => import('./../pages/User'))

const routes = [
    {
        path: '/',
        element: <Navigate to="/home"/>
    },
    {
        path: '/home',
        element: <Home/>,
        children: [
            {
                path: '/home',
                element: <Navigate to="/home/recommend"/>
            },
            {
                path: '/home/recommend',
                element: <HomeRecommend/>
            },
            {
                path: '/home/ranking',
                element: <HomeRanking/>
            },
            {
                path: '/home/song',
                element: <HomeSong/>
            }
        ],
    },
    {
        path: '/profile',
        element: <Profile/>
    },
    {
        path: '/login',
        element: <Login/>
    },
    {
        path: '/category',
        element: <Category/>
    },
    {
        path: '/mall',
        element: <Mall/>
    },
    {
        path: '/detail/:id',
        element: <Detail/>
    },
    {
        path: '/user',
        element: <User/>
    },
    {
        path: '*',
        element: <NotFound/>
    },
]
export default routes;